package com.tedu.bill.demo4;

import java.io.*;

/**
 * Author：毕龙
 * Date: 2024/5/28 9:24
 */
public class TestFile5 {
    public static void main(String[] args) {
        FileInputStream fis = null;
        Reader reader = null;
        BufferedReader br = null;
        OutputStreamWriter osw = null;
        BufferedWriter bw = null;
        try {
            //创建字节流
            fis = new FileInputStream("day14/src/test.txt");
            //转化流 将字节流转化为字符流
            reader = new InputStreamReader(fis);
            //将字符流转化为过滤流
            br = new BufferedReader(reader);

            //创建字符输出流
            osw = new OutputStreamWriter(new FileOutputStream("day14/src/test1.txt"));
            //创建缓冲流
            bw = new BufferedWriter(osw);

            //获取系统当前的时间戳
            long t1 = System.currentTimeMillis();
            String str;
            while ((str = br.readLine()) != null){
                //在控制台中输出
                System.out.print(str);
                //复制到另一个文件中
                bw.write(str);
                bw.newLine();
            }
            long t2 = System.currentTimeMillis();
            //获取时间
            System.out.println(t2-t1);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            //关闭流
            try {
                bw.close();
                osw.close();
                br.close();
                reader.close();
                fis.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        }





    }
}
